home *** CD-ROM | disk | FTP | other *** search
/ com!online 2005 May / com_0505_1.iso / opensource / top10 / amc_install.exe / {app} / Scripts / DVDSpecial (RU).ifs < prev    next >
Encoding:
Text File  |  2003-08-15  |  6.7 KB  |  248 lines

  1. // GETINFO SCRIPTING
  2. // Imports russian movies info with small picture from DVDSpecial.ru
  3. //    (±) Dmitry501 2003
  4. program DVDSpecial;
  5. const
  6.   BaseAddress = 'http://www.dvdspecial.ru/';
  7. var
  8.   MovieName: string;
  9.  
  10. function ParseURL(Text:String):String;
  11. var
  12.   BeginPos : Integer;
  13.   EndPos : Integer;
  14.   Value : String;
  15. begin
  16.  
  17.   repeat
  18.     BeginPos := Pos('<b>',Text);
  19.     If BeginPos > 0 Then
  20.     Begin
  21.       EndPos := Pos('</b>',Text);
  22.       Value := copy(Text, BeginPos, EndPos - BeginPos);
  23.       Value := StringReplace(Value,'<BR>',', ');
  24.       Value := StringReplace(Value,'<br>',', ');
  25.       HTMLRemoveTags(Value);
  26.       Delete(Text,1,EndPos);
  27.       If Length(result)>0 Then
  28.         result := result + ', ' + Value
  29.       else
  30.         result := Value;
  31.     end;
  32.   until BeginPos < 1;
  33.  
  34. end;
  35.  
  36. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  37. var
  38.   i: Integer;
  39. begin
  40.   result := -1;
  41.   if StartAt < 0 then
  42.     StartAt := 0;
  43.   for i := StartAt to List.Count-1 do
  44.     if Pos(Pattern, List.GetString(i)) <> 0 then
  45.     begin
  46.       result := i;
  47.       Break;
  48.     end;
  49. end;
  50.  
  51. procedure AnalyzePage(Address: string);
  52. var
  53.   ID, FilmName, Line: String;
  54.   Page: TStringList;
  55.   FilmPage: TStringList;
  56.   BeginPos, EndPos: Integer;
  57. begin
  58.   Page := TStringList.Create;
  59.   Page.Text := GetPage(Address);
  60.   BeginPos := FindLine('<B>╘╚╦▄╠█', Page,0);
  61.   if  BeginPos> 0 then
  62.     begin
  63.       //┬√ΓεΣ ⌠Φδⁿ∞εΓ Γ Σσ≡σΓε
  64.       Line:= Page.GetString(BeginPos+1); //╧εδ≤≈Φ≥ⁿ ±≥≡εΩ≤ ± αΣ≡σ±α∞Φ
  65.       PickTreeClear; //╬≈Φ±≥Ωα Σσ≡σΓα ⌠Φδⁿ∞εΓ
  66.       PickTreeAdd('╧εΦ±Ω ∩ε ±δεΓ≤: ' + MovieName, '');
  67.       repeat
  68.       BeginPos := Pos('<A HREF="film.phtml?film_id',Line);
  69.       If BeginPos>0 Then
  70.       Begin
  71.         Delete(Line,1,BeginPos); //╙ΣαδσφΦσ φα≈αδα
  72.         BeginPos:=9;
  73.         EndPos := Pos('" >  ',Line);
  74.         ID := copy(Line, BeginPos, EndPos - BeginPos); //╧εδ≤≈Φ≥ⁿ αΣ≡σ± ±≥≡αφΦ÷√
  75.         BeginPos := Pos('  ',Line)+11;
  76.         Delete(Line,1,BeginPos); //╙ΣαδσφΦσ Σε φατΓαφΦ 
  77.         BeginPos := 1;
  78.         EndPos := Pos('</A></TD>',Line)-1;
  79.         FilmName := Copy(Line, BeginPos, EndPos); //╧εδ≤≈Φ≥ⁿ φατΓαφΦσ Σδ  Γ√ßε≡α
  80.         FilmName := StringReplace(FilmName,' ',' ');
  81.         PickTreeAdd(FilmName, BaseAddress + ID);
  82.       end;
  83.       until BeginPos < 1;
  84.     end;
  85.   If  PickTreeExec(Address) Then
  86.       AnalyzeMoviePage(Address); //╧≡εαφαδΦτΦ≡εΓα≥ⁿ ±≥≡αφΦ÷≤ ± ⌠Φδⁿ∞ε∞
  87. end;
  88.  
  89. procedure AnalyzeMoviePage(Address: String);
  90. var
  91.   Page: TStringList;
  92.   LineNr : Integer;
  93.   Line, Value : String;
  94.   BeginPos, EndPos : Integer;
  95.  
  96. begin
  97.   Page := TStringList.Create;
  98.   Page.Text := GetPage(Address);
  99.   //Page.SaveToFile('c:\inet\page.txt'); //!╬≥δαΣΩα
  100.  
  101.   // URL
  102.   SetField(fieldURL,Address);
  103.  
  104.   //Rating
  105.  
  106.   LineNr := FindLine('IMDB:', Page, 0);
  107.   if LineNr > -1 then
  108.   begin
  109.     Line := Page.GetString(LineNr+3);
  110.     BeginPos := Pos('title=',Line)+7;
  111.     EndPos := Length(Line);
  112.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  113.     HTMLDecode(Value);
  114.     HTMLRemoveTags(Value);
  115.     Value := Trim(Left(StringReplace(Value, '.', '   '),2));
  116.     Value := IntToStr(StrToInt(Value,0));
  117.     SetField(fieldRating,Value);
  118.   end;
  119.  
  120.   // Translated Title
  121.   LineNr := FindLine('<font class=titul> ', Page, 0);
  122.   if LineNr > -1 then
  123.   begin
  124.     Line := Page.GetString(LineNr);
  125.     HTMLDecode(Line);
  126.     HTMLRemoveTags(Line);
  127.     Value := Trim(Line);
  128.     SetField(fieldTranslatedTitle,Value);
  129.   end;
  130.   
  131.   // Original Title
  132.   LineNr := FindLine('╬≡ΦπΦφαδ:', Page, 0);
  133.   if LineNr > -1 then
  134.   begin
  135.     Line := Page.GetString(LineNr+1);
  136.     BeginPos := pos('<b>', Line);
  137.     EndPos := Length(Line);
  138.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  139.     SetField(fieldOriginalTitle, Value);
  140.   end;
  141.  
  142.   // Year
  143.   LineNr := FindLine('┬√∩≤∙σφ:', Page, 0);
  144.   if LineNr > -1 then
  145.   begin
  146.     Line := Page.GetString(LineNr+1);
  147.     BeginPos := pos('<b>', Line);
  148.     EndPos := Length(Line);
  149.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  150.     SetField(fieldYear, Value);
  151.   end;
  152.  
  153.   //Category
  154.   LineNr := FindLine('╞αφ≡:', Page, 0);
  155.   if LineNr > -1 then
  156.   begin
  157.     Line := Page.GetString(LineNr+1);
  158.     BeginPos := pos('<b>', Line);
  159.     EndPos := Length(Line);
  160.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  161.     SetField(fieldCategory, Value);
  162.   end;
  163.  
  164.   //Country
  165.   LineNr := FindLine('╤≥≡αφα:', Page, 0);
  166.   if LineNr > -1 then
  167.   begin
  168.     Line := Page.GetString(LineNr+1);
  169.     BeginPos := pos('<b>', Line);
  170.     EndPos := Length(Line);
  171.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  172.     SetField(fieldCountry, Value);
  173.   end;
  174.  
  175.   // Director
  176.   LineNr := FindLine('≡σµΦ±±σ≡:', Page, 0);
  177.   if LineNr > -1 then
  178.   begin
  179.     Line := Page.GetString(LineNr+1);
  180.     BeginPos := pos('<b>', Line);
  181.     EndPos := Length(Line);
  182.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  183.     SetField(fieldDirector, Value);
  184.   end;
  185.  
  186.   // Producer
  187.   LineNr := FindLine('∩≡εΣ■±σ≡:', Page, 0);
  188.   if LineNr > -1 then
  189.   begin
  190.     Line := Page.GetString(LineNr+1);
  191.     BeginPos := pos('<b>', Line);
  192.     EndPos := Length(Line);
  193.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  194.     SetField(fieldProducer, Value);
  195.   end;
  196.  
  197.   // Actors
  198.   LineNr := FindLine('┬ ≡εδ ⌡:', Page, 0);
  199.   if LineNr > -1 then
  200.   begin
  201.     Line := Page.GetString(LineNr+1);
  202.     BeginPos := pos('<b>', Line);
  203.     EndPos := Length(Line);
  204.     Value := ParseURL(copy(Line, BeginPos, EndPos - BeginPos));
  205.     SetField(fieldActors, Value);
  206.   end;
  207.  
  208.   // Description
  209.   LineNr := FindLine('<div align=justify>', Page, 0); //═α≈αδε ±≥≡εΩΦ ε∩Φ±αφΦ 
  210.   if LineNr > -1 then
  211.   begin
  212.     Line := '';
  213.     Repeat
  214.       Line := Line + Page.GetString(LineNr+1);
  215.       LineNr := LineNr+1;
  216.       EndPos := Pos('</div>',Line);
  217.     Until EndPos > 0 ;
  218.     HTMLDecode(Line);
  219.     HTMLRemoveTags(Line);
  220.     Value := Trim(Line);
  221.     SetField(fieldDescription,Value);
  222.   end;
  223.  
  224.   // Picture
  225.   LineNr := FindLine('<center><img src=', Page, 0); //═α≈αδε ±≥≡εΩΦ ± ≡Φ±≤φΩε∞
  226.   if LineNr > -1 then
  227.   begin
  228.     Line := Page.GetString(LineNr);
  229.     BeginPos := 20;
  230.     EndPos := pos('" ', Line);
  231.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  232.     Address := BaseAddress+Value;
  233.     If Value <> 'foto/logo.gif' Then
  234.     begin
  235.       GetPicture(Address, False);
  236.     end;
  237.   end;
  238. DisplayResults;
  239. end;
  240.  
  241. begin
  242.     MovieName := GetField(fieldOriginalTitle);
  243.     if MovieName = '' then
  244.       MovieName := GetField(fieldTranslatedTitle);
  245.     if Input('Import from DVDSpecial', 'Enter the title of the movie:', MovieName) then
  246.       AnalyzePage('http://www.dvdspecial.ru/search.phtml?keywords='+UrlEncode(MovieName)+'&target=all&logic=AND');
  247. end.
  248.